#ifndef VIDEO_PLAYER__VIDEO_PLAYER_NODE_HPP_
#define VIDEO_PLAYER__VIDEO_PLAYER_NODE_HPP_

#include "rclcpp/rclcpp.hpp"
#include "image_transport/image_transport.hpp"
#include "sensor_msgs/msg/image.hpp"
#include "sensor_msgs/msg/camera_info.hpp"
#include "camera_info_manager/camera_info_manager.hpp"
#include <opencv2/opencv.hpp>
#include <memory>
#include <thread>

namespace video_player {

class VideoPlayerNode : public rclcpp::Node
{
public:
  explicit VideoPlayerNode(const rclcpp::NodeOptions &options);
  ~VideoPlayerNode() override;

private:
  // 核心初始化函数
  bool initVideoCapture();
  void createImagePublisher();
  void loadCameraInfo();
  void startPublishThread();

  // 视频捕获对象
  cv::VideoCapture cap_;
  int frame_width_;
  int frame_height_;
  double fps_;

  // 图像发布相关
  image_transport::CameraPublisher camera_pub_;
  sensor_msgs::msg::Image image_msg_;
  sensor_msgs::msg::CameraInfo camera_info_msg_;
  std::unique_ptr<camera_info_manager::CameraInfoManager> camera_info_manager_;

  // 发布线程
  std::thread publish_thread_;
};

}  // namespace video_player

#endif  // VIDEO_PLAYER__VIDEO_PLAYER_NODE_HPP_